cc_binary(
    name = "example1_plugin.so",
    srcs = ["example1/plugin.cc"],
    linkshared = True,
)

cc_binary(
    name = "example1_main",
    srcs = ["example1/main.cc"],
    linkopts = ["-ldl"],
)

cc_library(
    name = "example2_plugin_api",
    hdrs = [
        "example2/shared/plugin_api.h",
        "example2/shared/so_wrapper.h",
    ],
    includes = ["example2/shared"],
)

# 插件实现 (生成 .so 动态库)
cc_binary(
    name = "example2_plugin.so",
    srcs = ["example2/plugin/plugin.cc"],
    linkshared = True,  # 关键：生成 .so 而不是可执行程序
    deps = [":example2_plugin_api"],
)

# 主程序 (依赖 API，运行时用 dlopen 加载 plugin.so)
cc_binary(
    name = "example2_main",
    srcs = ["example2/main.cc"],
    linkopts = ["-ldl"],  # 必须加上 libdl
    deps = [":example2_plugin_api"],
)

# 主程序 (依赖 API，运行时用 dlopen 加载 plugin.so)
cc_binary(
    name = "example2_main2",
    srcs = ["example2/main2.cc"],
    linkopts = ["-ldl"],  # 必须加上 libdl
    deps = [":example2_plugin_api"],
)

cc_binary(
    name = "typeid_example",
    srcs = ["typeid_example.cc"],
)

cc_binary(
    name = "example3_main",
    srcs = ["example3/main.cc"],
)
